﻿using System;
using PTiRouZ.Net.SilverLight.Api;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;

namespace PTiRouZ.Net.SilverLight.Api.HelloTipi
{
    /*id = int (identifiant de l’utilisateur)
name = char (nom complet de l’utilisateur)
screen_name = char (identifiant de l’utilisateur suivi de sa famille login#famille)
location = char (non utilisé)
description = char (non utilisé)
profile_image_url = char (url de l’image du profil de l’utilisateur)
url = char (url du profil de l’utilisateur)
protected = bool (non utilisé)
followers_count = int (non utilisé)*/

    /// <summary>Objet correspondant à la requete statuses/featured</summary>
    /// <see cref="featured"></see>
    public class featured
    {
        /// <summary>Id de l'utilisateur</summary>
        [DataMember]
        public int id { get; set; }

        /// <summary>nom complet de l’utilisateur</summary>
        [DataMember]
        public string name { get; set; }

        /// <summary>Pseudonyme de l'utilisateur</summary>
        [DataMember]
        public string screen_name { get; set; }

        //location = char (non utilisé)
        //description = char (non utilisé)

        /// <summary>url de l'avatar du user</summary>
        /// <remarks>url valide 1h</remarks>
        [DataMember]
        public string profile_image_url { get; set; }

        /// <summary>url du profil de l’utilisateur</summary>
        [DataMember]
        public string url { get; set; }

        //protected = bool (non utilisé)
        //followers_count = int (non utilisé)        
    }

    public delegate void FeaturedEventHandler(object sender, FeaturedEventArgs e);

    public class FeaturedEventArgs : EventArgs
    {
        public FeaturedEventArgs(featured s)
        {
            _result = s;
        }

        private featured _result;
        public featured result { get { return _result; } }
    }
    public partial class apitxt : api
    {

        public event FeaturedEventHandler FeaturedCompleted;

        /// <summary>Pour l’utilisateur authentifié, retourne la liste de ses contacts de toutes ses familles étant actuellement connectés sur www.hellotipi.com.</summary>
        /// <returns>Retourne une structure <see cref="featured"/></returns>
        /// <example>http://apitxt.hellotipi.com/statuses/featured.json</example>
        public void Featured(string id)
        {
            base.APICallCompleted += new APICallCompletedEventHandler(FeaturedCallCompleted);
            GetUrlApi("statuses/featured.json");
        }

        void FeaturedCallCompleted(object sender, ApiOpenReadCompletedEventArgs e)
        {
            try
            {
                FeaturedCompleted.Invoke(sender, new FeaturedEventArgs(serializeTools.Deserialize<featured>(e.Result)));
            }
            finally
            {
                base.APICallCompleted -= new APICallCompletedEventHandler(FeaturedCallCompleted);
            }
        }

    }
}
